{	Problem: http://codeforces.ru/problemset/problem/48/D
	Verdict: Accepted
}
{$R+,S+,Q+,I+,C+,M+,O-}
uses SysUtils;
var i,n,m:longint; a,b,c:array[1..100010] of longint;  f:boolean;
begin
read(n);
fillchar(b,sizeof(b),0);
fillchar(c,sizeof(c),0);
m:=0;
for i:=1 to n do begin
  read(a[i]);
  inc(b[a[i]]);
  if a[i]>m then m:=a[i];
end;
f:=true;
for i:=2 to m do
  if not(b[i]<=b[i-1]) then f:=false;
if f then begin
  writeln(b[1]);
  for i:=1 to n do begin
    inc(c[a[i]]);
    write(c[a[i]],' ');
  end;
end else write(-1);
end.